package com.sitech.openapi.domain;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@ApiModel(value = "test",description = "工号DTO")
public class Test {

    @ApiModelProperty(value = "工号姓名",example = "张三")
    private String name;
    @ApiModelProperty(value = "工号Code",example = "123321")
    private String code;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }


    public static void main(String [] args){



        //创建固定大小的线程池
        ExecutorService fPool = Executors.newFixedThreadPool(3);
        //创建缓存大小的线程池
        ExecutorService cPool = Executors.newCachedThreadPool();
        //创建单一的线程池
        ExecutorService sPool = Executors.newSingleThreadExecutor();


        /*MainThread mainThread = new MainThread();
        new Thread(()->{
            for (int i = 0; i < 3; i++) {

                mainThread.subThread();
            }
        }).start();

        for (int i = 0; i < 3; i++) {
            mainThread.mainThread();
        }*/


    }

    static class MainThread{
        private boolean flag = true;

        public synchronized void subThread(){
            while(flag){
                try {
                    wait();
                }catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            for (int i = 0; i < 5; i++) {
                System.out.println("子线程在运行！"+i);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            flag = true;
            notify();
        }
        public synchronized void mainThread(){
            while(!flag){
                try {
                    wait();
                }catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            for (int i = 0; i < 10; i++) {
                System.out.println("main线程在运行啊啊啊！"+i);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            flag = false;
            notify();
        }
    }
}
